#client-build
FROM node:alpine as build-client
ADD ./client/package.json /application/client/
ADD ./client/jsconfig.json /application/client/
#ADD ./client /application
WORKDIR /application/client
RUN npm config set registry http://registry.npm.taobao.org && \
    npm config set @wanhu:registry http://10.1.10.47:5080
ADD ./client ./
RUN npm install
RUN npm run build && rm -rf node_modules

#server-build
FROM node:alpine as build-server
ADD ./server /application/server/
RUN npm config set registry http://registry.npm.taobao.org && \
    npm config set @wanhu:registry http://10.1.10.47:5080
RUN cd /application/server && npm install loadsh && npm install --production && \
    npm cache clean --force

#last-build
FROM 10.1.10.47:5000/node-base:8
COPY --chown=docker-client:docker-client --from=build-client /application/client /application/client
COPY --chown=docker-client:docker-client --from=build-server /application/server /application/server
WORKDIR /application/server
ENTRYPOINT ["/application/server/node_modules/.bin/egg-framework-wanhu-run", "start"]
